<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no" />
		<title>速翔网络 - QQ技术：1424445608</title>
		<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
		<link rel="stylesheet" type="text/css" href="../../css/yaoqing.css" />
	 	<style>
	 		.sx-view .sx-yq-list-2:nth-child(1) div:nth-child(1){
	 		 	background: url('../../image/yaoqing/top_icon1_2.png') no-repeat center;
	 		 	background-size: 25% 100%;
	 		  	text-indent:-9999px;
	 		 }
	 		 .sx-view .sx-yq-list-2:nth-child(2) div:nth-child(1){
	 		 	background: url('../../image/yaoqing/top_icon2_2.png') no-repeat center;
	 		 	background-size: 25% 100%;
	 		  	text-indent:-9999px;
	 		 }
	 		 .sx-view .sx-yq-list-2:nth-child(3) div:nth-child(1){
	 		 	background: url('../../image/yaoqing/top_icon3_2.png') no-repeat center;
	 		 	background-size:25% 100%;
	 		  	text-indent:-9999px;
	 		 }
	 	</style>
	</head>
	<body>
		<div class="aui-content sx-yq-1">
			<div class="sx-yq-2">
				<div class="sx-yq-btn" tapmode onclick="fenxiang()">立即收徒</div>
				<p tapmode onclick="_url({url:'yaoqing/about',title:'收徒奖励'})"></p>
			</div>
		 
		<!--	<div class="sx-yq-3" tapmode onclick="_url({url:'about',id:'3',title:'如何收徒'})">
                如何收徒
            </div>-->
         <!--   <div class="sx-yq-4" tapmode onclick="_url({url:'about',id:'4',title:'奖励规则'})">
                奖励规则
            </div>-->
		</div>
		<div class="aui-content sx-yq-5">
			<div class="aui-tab">
			    <div class="aui-tab-item aui-active" data-id='1' data-list='1'>我的收徒</div>
		<!--	    <div class="aui-tab-item" data-id='2' data-list='0'>我的收徒</div>-->
			    <div class="aui-tab-item" data-id='3' data-list='0'>奖励明细</div>
			</div>
			<div class="sx-tab-list sx-yq-list1">
				<div class="aui-card-list-footer sx-yq-list2-1">
					<div>昵称</div>
					<div>加入时间</div>
				</div>
				<div class="sx-view"><div id="jiazai"><img src="../../image/loading_more.gif" /></div></div>
			</div>
			<div class="sx-tab-list sx-yq-list2" style=" display: none;">
				<div class="aui-card-list-footer sx-yq-list2-1">
					<div>昵称</div>
					<div>加入时间</div>
				</div>
				<div class="sx-view"><div id="jiazai"><img src="../../image/loading_more.gif" /></div></div>
			</div>
			<div class="sx-tab-list sx-yq-list3" style=" display: none;">
				<ul class="sx-view aui-list aui-media-list"><div id="jiazai"><img src="../../image/loading_more.gif" /></div></ul>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/fastclick.js"></script>
	<script type="text/javascript" src="../../script/zepto.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/ffxiang.js"></script>
	<script type="text/javascript">
		var name='zongbang/type/2',type=tabList1=tabList2=tabList3=1,heigutgao=0,Gao1=Gao2=Gao3=0,fx_data;
		apiready = function() {

			//console.log(api.winName+api.frameName)
			$('.sx-yq-1 p').html('我的邀请码： <b>'+_user.id+'</b>  >');
	 		list();
	 		_shangla(function(ret,err){
	 			// 递增页面
				switch(type)
					{
					case 2:
						tabList2=1
					  	break;
					case 3:
						tabList3=1
					  	break;
					default:
						tabList1=1
				}
				list()
			},1)
	 	 
			FastClick.attach(document.body);
			// tab点击
			$(function(){
				$('.aui-tab .aui-tab-item').click(function(){
					heigutgao=0;
					var _this=$(this);
					$('.aui-active').removeClass('aui-active');
					_this.addClass('aui-active');
					type=_this.data('id');
					$('.sx-tab-list').hide();
					$('.sx-yq-list'+type).show();
					// data-list= 0 未打开 1已打开
					var dada_list=_this.data('list');
					if(!dada_list){
						_this.data('list',1)
						list();
					}
				})
			})
			
			// 监听滚动
			api.addEventListener({
				name : 'scrolltobottom',
				extra : {
					threshold : threshold //设置距离底部多少距离时触发，默认值为0，数字类型
				}
			}, function(ret, err) {
			 
				if (Gao1 == 1 && type==1) {
					Gao1 = 0
					tabList1=tabList1+1
					list(tabList1)
				}else if(Gao2==1 && type==2){
					Gao2 = 0
					tabList2=tabList2+1
					list(tabList2)
				}else if(Gao3==1 && type==3){
					Gao3 = 0
					tabList3=tabList3+1
					list(tabList3)
				}
				
			});
		}
		 
	
		function list(pages){
			pages=pages ? pages : 1;
			_ajax('api/yaoqing/'+_name() + '?page=' + pages,function(ret,err){
				if(ret){
					console.log(JSON.stringify(ret))
					_loadingCloes()
					var _this=$('.sx-yq-list'+type+' .sx-view');
					page_total = ret.total
					if(!page_total){
						_this.html('<div id="tishi">暂无数据</div>');
						return;
					}
					// 获取得到数据线删除底部加载提示
					if(pages != 1){
						$('.sx-yq-list'+type+' .sx-view .fx-dibu_loading').remove();
					}
					
					console.log(pages)
					var html=''
					for(var i=0;i<ret.data.length;i++){
						if(type==2){
							html += '<div class="aui-card-list-footer sx-yq-list2-2">';
							html += '<div>'+ret.data[i].username+'</div>';
							html += '<div>'+ret.data[i].time+'</div>';
							html += '</div>';
						}else if(type==3){
							html += '<li class="aui-list-item">';
							html += '<div class="aui-media-list-item-inner">';
							html += '<div class="aui-list-item-inner">';
							html += '<div class="aui-list-item-text">';
							html += '<div class="aui-list-item-title">'+ret.data[i].username+'</div>';
							html += '<div class="aui-list-item-right">'+ret.data[i].time+'</div>'
							html += '</div>';
							html += '<div class="aui-list-item-text aui-ellipsis-1">'+ret.data[i].content+'</div>';
							html += '</div>';
							html += '</div>';
							html += '</li>';
						}else{
							html += '<div class="aui-card-list-footer sx-yq-list2-2">';
							html += '<div>'+ret.data[i].username+'</div>';
							html += '<div>'+ret.data[i].time+'</div>';
							html += '</div>';
						}
					}
					 
					// 插入底部加载提示
					page_per_page = Math.ceil(page_total / ret.per_page);
					if (page_per_page <= pages) {
						// 递增页面
						switch(type)
						{
						case 2:
							Gao2=0
						  	break;
						case 3:
							Gao3=0
						  	break;
						default:
							Gao1=0
						}
						html += '<div id="loadingNo">底部没有数据了...</div>';
					}else {
						// 递增页面
						switch(type)
						{
						case 2:
							Gao2=1
						  	break;
						case 3:
							Gao3=1
						  	break;
						default:
							Gao1=1
						}
						html += '<div class="fx-dibu_loading load-container loadingdi"><div class="loader">loadingdi...</div></div>';
					}
					 
					if(pages==1 || !pages){
						_this.html(html);
					}else{
						_this.append(html);
					}
				 	
				 	 
				}else{
					alert(JSON.stringify(err))
				}
			})
		}
		// 链接
		function _name(){
			switch(type)
			{
			case 2:
			name='zongbang/type/2'
			  break;
			case 3:
			name='mingxi'
			  break;
			default:
				name='zongbang/type/2'
			}
		//	console.log(name)
			return name;
		}
		// 2018年3月1日 12:49:24
		function fenxiang() {
			if(!$api.getStorage('user')){
				_login();
				return;
			}
			
			 
			fx_data={
				title:_config.yaoqing.fenxiang_title,
				description:_config.yaoqing.fenxiang_content,
				img:_image+'logo.png',
				url:fx_url+'m/yaoqing/uid/'+$api.getStorage('user').id
			}
			
				
//			if($api.getStorage('app')){
//				// 上架显示
//				var sharedModule = api.require('shareAction');
//				sharedModule.share({
//					text : fx_data.title + fx_data.content,
//					type : 'text'
//				});
//				return;
//			}
			var row=2;
			var items=[{icon: _image+'share/1.png',title: '朋友圈'},{icon: _image+'share/2.png',title: '好友'},{icon: _image+'share/3.png',title: 'QQ'},{icon: _image+'share/4.png',title: '空间'},{icon: _image+'share/5.png',title:'微博'},{icon: _image+'share/101.png',title: '系统'},{icon: _image+'share/102.png',title: '短信'},{icon: _image+'share/103.png',title:'邮件'},{icon: _image+'share/104.png',title: '复制链接'}];
			// alert(1)
			console.log(JSON.stringify(fx_data))
		 
 			var MNActionButton = api.require('MNActionButton');
			MNActionButton.open({
			    layout: {
			        row: row,
			        col: 5,
			        offset: 0
			    },
			    animation: false,
			    autoHide: true,
			    styles: {
			        maskBg: 'rgba(0,0,0,0.3)',
			        bg: '#F8F8F8',
			        indicator: {
			            color: '#c4c4c4',
			            highlight: '#9e9e9e'
			        }, 
			    },
			    items:  items
			}, function(ret) {
				if(ret.eventType=="click"){
					var index=ret.index;
					if(index==0){
						_weixin('timeline',fx_data)
					}else if(index==1){
						_weixin('session',fx_data)
					}else if(index==2){
						_qq('shareNews',fx_data)
					}else if(index==3){
						_qq('QFriend',fx_data)
					}else if(index==4){
						_weibo(fx_data)
					}else if(index==5){	// 系统
						var sharedModule = api.require('shareAction');
						sharedModule.share({
							text : fx_data.title + fx_data.content,
							type : 'text'
						});
					}else if(index==6){	// 短信
						api.sms({
							numbers : [],
							text : fx_data.title+fx_data.url
						}, function(ret, err) {
							if (ret && ret.status) {
								_msg('已发送')
							} 
						});
					}else if(index==7){	// 邮件
						api.mail({
							recipients : [],
							subject : fx_data.title,
							body : fx_data.content+fx_data.url,
						}, function(ret, err) {
							if (ret && ret.status) {
								_msg('已发送')
							}
						});
					}else if(index==8){	// 复制
						var clipBoard = api.require('clipBoard');
						clipBoard.set({
							value : fx_data.url
						}, function(ret, err) {
							if (ret) {
								_msg('复制成功，把链接分享给朋友吧！')
							}
						});
					}else if(index==9){	//举报
						if(!_user){
							_alert('请先登录',function(ret,err){
								_login();
							})
							return;
						}
						buttons = ['广告', '重复、旧闻', '低俗', '标题夸张', '与事实不符', '内容质量差', '疑似抄袭', '其他问题，我要吐槽 > '];
						api.actionSheet({
							title : '举报内容问题',
							cancelTitle : '取消举报',
							buttons : buttons
						}, function(ret, err) {
							var index = ret.buttonIndex;
							if(index==8){
								_url({aid:id,url:'member/jubaoAdd',title:'举报内容'})
								return;
							}
							if(index!=9){
								_ajax('api/member/jubao',function(ret,err){
									if(ret){
										if(ret.ret){
											_msg(ret.ret)
										}else{
											_msg(ret.err)
										}
									}else{
										_alert(JSON.stringify(err));
									}
								},{content:buttons[index - 1],aid:id})
							}
						});
					}else{
						_msg(index)
						return;
					}
				}
			});
		}
		// 微信分享
		// type session（会话） timeline（朋友圈） favorite（收藏）
		function _weixin(type) {
			if(!$api.getStorage('user')){
				_login();
				return;
			}
			data=fx_data;
			var wx = api.require('wx');
			wx.shareWebpage({
				scene : type,
				title : data.title,
				description : data.description,
				thumb : data.img,
				contentUrl : data.url
			}, function(ret, err) {
				if (ret.status) {
					_msg('分享成功');
					_daily({name:'money_fenxiang_1'});
				}
			});
		}
		// QQ分享
		// type 分享内容到好友或空间，取值范围：QZone、QFriend
		function _qq(type){
			if(!$api.getStorage('user')){
				_login();
				return;
			}
			data=fx_data;
			var obj = api.require('qq');
			obj.shareNews({
				url : data.url,
				title : data.title,
				description : data.description,
				imgUrl : data.img,
				type : type,
			}, function(ret, err) {
				if (ret.status) {
					_msg('分享成功');
					_daily({name:'money_fenxiang_1'});
				} 
			});
		}
		// 微博分享
		function _weibo() {
			if(!$api.getStorage('user')){
				_login();
				return;
			}
			data=fx_data;
			var weibo = api.require('weibo');
			weibo.shareWebPage({
				text : data.title,
				title : data.title,
				description : data.description,
				thumb : data.img,
				contentUrl : data.url
			}, function(ret, err) {
				if (ret.status) {
					_msg('分享成功');
					_daily({name:'money_fenxiang_1'});
				}
			});
		}
	</script>
</html>